<extend name="work/base" />
<block name="content">
    <div class="data-list" data-url="{:url('lists')}">
        <form class="layui-form inline-form">
            <div class="pull-left">
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-normal layui-btn-sm ajax-form" data-url="{:url('add')}" title="添加角色"><i class="layui-icon">&#xe61f;</i> 添加角色</button>
                </div>
            </div>
        </form>
        <table class="layui-table text-center" id="list" lay-filter="list" list-url="{:url('lists')}" edit-url="{:url('edit')}" del-url="{:url('delete')}" assigned-url="{:url('/goods/goods/add')}"></table>
    </div>
</block>
<block name="script">
    <script type="text/html" id="barDemo">
        <a class="layui-btn  layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn  layui-btn-xs ajax-form-no"  href="{:url('assigned')}?id={{d.id}}">权限</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
    </script>
    <script type="text/html" id="status">
        <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="正常|禁用" lay-filter="is_view" {{ d.status ==1?'checked' : '' }}>
    </script>
    <script type="text/javascript">
        layui.use([ 'element', 'table'], function(){
            var table = layui.table;
            table.render({
                elem: '#list'
                ,url:"{:Url('lists')}"
                ,page:true
                ,loading:true
                ,limit:20
                ,title:'用户表'
                ,cols: [[
                    {field:'title', width:160, title: '角色名称', edit: 'text'}
                    ,{field:'status', width:200, title: '禁用/正常', templet:'#status'}
                    ,{field:'remark', width:850, title: '描述', edit: 'text'}
                    ,{fixed: 'right', width:215,title:'操作',  toolbar:'#barDemo'}
                ]]
            });
        });
    </script>
</block>
</block>